package com.example.bootclockin.Controller;

import com.example.bootclockin.mapper.TodosMapper;
import com.example.bootclockin.pojo.Todos;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;


import java.util.List;

@RestController
@ResponseBody
@Transactional
@CrossOrigin(origins = "*", maxAge = 3600)
@RequestMapping("/todos")
public class TodosController {
    @Autowired
    TodosMapper todosMapper;

    @RequestMapping("/show/{date}")
    public List<Todos> showall(@PathVariable String date){
        return todosMapper.showbydate(date);
    }

    @RequestMapping("/insert/{date}/{time}")
    public int getupinsert(@PathVariable String date,@PathVariable String time){
        return todosMapper.getupinsert(date,time);
    }

    @RequestMapping("/update/{date}/{title}/{time}")
    public int update(@PathVariable String date,@PathVariable String title,@PathVariable String time){
        return todosMapper.clockin(date,title,time);
    }

}
